<template>
	<view class="">
		<view class="" style="padding: 32rpx;margin-bottom: 4rpx;background: #fff;">
			<view class="flex align-center" style="background: #F3F3F3;padding: 14rpx 24rpx;">
				<view class="" style="font-size: 0;margin-right: 14rpx;">
					<image style="height: 40rpx;width: 40rpx;" src="static/5.png" mode=""></image>
				</view>
				<input class="flex-1" @input="search" v-model="keywords" type="text" placeholder="搜索">
			</view>
		</view>
		<view v-if="reviewList.length==0" class="" style="font-size: 26rpx;color: #999999;text-align: center;padding-top: 30rpx;">
			暂无数据!
		</view>
		<view class="flex align-center justify-between" v-for="(item,index) in reviewList" :key="index" style="padding: 20rpx 32rpx;border-bottom: 2rpx solid #f2f2f2;background: #fff;">
			<view class="flex align-center">
				<view class="flex align-center">
					<view class="" style="font-size: 0;margin-right: 20rpx;">
						<image style="width: 84rpx;height: 84rpx;border-radius: 50%;" :src="item.userinfo.avatar" mode=""></image>
					</view>
				</view>
				<view class="flex flex-clum justify-between" style="height: 84rpx;">
					<view class="flex align-center" style="flex: 1;">
						<view class="" style="font-weight: 500;color: #333333;font-size: 30rpx;margin-right: 20rpx;">
							{{item.userinfo.name}}
						</view>
						<view class="flex align-center">
							<view class="" style="font-size: 26rpx;color: #333333;">
								{{item.userinfo.mobile}}
							</view>
							<view class="" @click="call(item.userinfo.mobile)" style="font-size: 0;margin-left: 10rpx;">
								<image style="width: 36rpx;height: 36rpx;" src="static/13.png" mode=""></image>
							</view>
						</view>
					</view>
					<view v-if="item.p_id==0" class=""style="font-size: 24rpx;color: #999999;">
						自主申请  {{item.createtime}}
					</view>
					<!-- <view v-else class="" style="font-size: 24rpx;color: #999999;">
						推荐人/{{item.puserinfo.name}}
					</view> -->
					<view v-else class="" style="font-size: 24rpx;color: #999999;">
						推荐人/{{item.puserinfo.name}}
					</view>
				</view>
			</view>
			<view v-if="item.type==0" class="flex align-center">
				<view class="" @click="agree(item,2)" style="font-size: 26rpx;color: #666666;margin-right: 36rpx;">
					拒绝
				</view>
				<view @click="agree(item,1)" class="flex align-center justify-center" style="width: 92rpx;height: 52rpx;background: linear-gradient(154deg, #E4B77F 0%, #CD9C61 100%);border-radius: 8rpx 8rpx 8rpx 8rpx;">
					同意
				</view>
			</view>
			<view v-else class="flex align-center justify-end" style="">
				<view v-if="item.type==1" class="" style="font-size: 0;">
					<image style="width: 30rpx;height: 30rpx;" src="./static/16.png" mode=""></image>
				</view>
				<view class="" style="font-size: 26rpx;color: #999999;">
					<!-- 1通过2驳回3邀请中4平台同意5拒绝邀请 -->
					{{
						item.type==1?'已同意':
						item.type==3?'邀请中':
						item.type==2?'驳回':
						item.type==4?'邀请中':
						item.type==5?'拒绝邀请':''
					}}
				</view>
			</view>
			<!-- <view class="flex justify-end" style="height: 84rpx;">
				<view class="" style="font-size: 26rpx;color: #333333;">
					{{item.mobile}}
				</view>
				<view class="" @click="call(item.mobile)" style="font-size: 0;margin-left: 10rpx;">
					<image style="width: 36rpx;height: 36rpx;" src="static/13.png" mode=""></image>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				reviewList:[],
				keywords:'',
				page:1,
				lastPage:0,
				shopId: 0,
			}
		},
		onLoad(options) {
			this.shopId = options.shop_id;
			this.getReviewList();
		},
		onReachBottom() {
			if(this.page<this.lastPage){
				this.page++;
				this.getReviewList();
			}else {
				this.$wanlshop.msg('我是有底线的')
			}
		},
		methods:{
			//同意
			agree(item,type){
				this.$request({
					url: 'partners/shop_partner_refurn',
					method: 'POST',
					data: {
						id: item.id,
						type
					},
				}).then(res => {
					if(res.data.code==1){
						if(type==1){
							uni.showToast({
								title:'已通过',
								icon:'none'
							})
						}else {
							uni.showToast({
								title:'已拒绝',
								icon:'none'
							})
						}
						this.page = 1;
						this.getReviewList();
					}else{
						uni.showToast({
							title:res.data.msg,
							icon:'none'
						})
					}
				})
			},
			// 搜索
			search(){
				this.page = 1;
				this.getReviewList();
			},
			//拨打电话
			call(e){
				uni.makePhoneCall({
					phoneNumber: e, //仅为示例
					success:res=>{
						
					},
					fail:res=>{
						
					}
				});
			},
			//审核列表
			getReviewList(){
				this.$request({
					url: 'partners/sh_list',
					method: 'POST',
					data: {
						keyword: this.keywords,
						page:this.page,
						shop_id: this.shopId,
					},
				}).then(res => {
					if(this.page==1){
						this.reviewList = res.data.data;
					}else {
						this.reviewList.push(...res.data.data);
					}
					this.lastPage = res.data.data.last_page;
				})
			}
		}
	}
</script>
<style>
	page {
		background: #F4F5F9;
	}
</style>
<style scoped lang="scss">
	.flex {
		display: flex;
	}
	.flex-1 {
		flex: 1;
	}
	.flex-clum {
		flex-direction: column;
	}
	.align-center {
		align-items: center;
	}
	.justify-around {
		justify-content: space-around;
	}
	.justify-between {
		justify-content: space-between;
	}
	.justify-center {
		justify-content: center;
	}
	.justify-end {
		justify-items: end;
	}
</style>